import Vue from 'vue'
import Router from 'vue-router'
import { constantRouterMap } from '@/config/router.config'
import dangerShowPage from '@/components/Danger/dangerShowPage' // 导入目标组件
import violationShowPage from '@/components/Violation/violationShowPage' // 导入目标组件

Vue.use(Router)
const originalPush = Router.prototype.push
Router.prototype.push = function push (location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  ...constantRouterMap,
  {
    path: '/dangerShowPage',
    name: 'DangerShowPage',
    component: dangerShowPage,
    props: route => ({ id: route.query.id })
  },
  {
    path: '/violationShowPage',
    name: 'ViolationShowPage',
    component: violationShowPage,
    props: route => ({ id: route.query.id })
  }
]

export default new Router({
  mode: 'hash',
  base: process.env.NODE_ENV,
  scrollBehavior: () => ({ y: 0 }),
  routes
})
